import qs from 'query-string'
import request from '../request'
import type { LoginData, LoginResponseData } from './type'

enum API {
  CREATECAPTCHA_URL = '/auth/captcha', // 生成验证码接口
  LOGIN_URL = '/auth/login', //登陆接口
}

// 生成验证码接口
export const reqCreateCaptcha = () =>
  request<string, any>({ url: API.CREATECAPTCHA_URL, method: 'get' })
// 登陆接口
export const reqLogin = (data: LoginData) =>
  request<LoginResponseData, any>({
    url: API.LOGIN_URL,
    method: 'post',
    data: qs.stringify(data),
  })
